<?php
namespace Admin\Controller;
use Think\Controller;


/**
* 后台登录
*/
class LoginController extends Controller
{
	public function index()
	{
	$this->display('Login/index');
		
	}
	
	public function login()
	{
		$admin['adm_name'] = $_POST['adminname'];
		$admin['adm_pwd'] = md5($_POST['adminpwd']);
		// var_dump($admin);
		$aduser = M('admin')->where($admin)->select();
		// var_dump($aduser);
		if (empty($aduser)) {
			$this->error('用户名或密码错误!',U('Admin/login/index'));
	    	exit;
		} else {
			$aduser=$aduser['0'];
			unset($aduser['pwd']);
			unset($aduser['email']);
			// unset($date['login_count']);
			unset($aduser['status']);
			session('home',$aduser);
			$tyu = session();
			// var_dump($tyu);
			// exit;
			$this->success('登录成功',U('Admin/index/index'));
		}
	}

}